﻿CREATE PROCEDURE ReportPMUnapprovedEntries
	(
		@managerID int
	)
AS
BEGIN
	select distinct p.Name, u.FullName, e.EntryDate, e.BillableHours
	from EntryLog e inner join
		 Projects p on e.ProjectID = p.ProjectID inner join
		  (select distinct u.UserID, u.FullName, u.UserName, u.IsActive
		   from Projects p inner join
				ProjectMembers pm on p.ProjectID = pm.ProjectID inner join
				Users u on u.UserID = pm.UserID
		   where p.ManagerUserID = @managerID) as u on e.UserID = u.UserID
	where e.BillingStateID = 1 and u.IsActive = 1 and p.ManagerUserID = @managerID
	order by p.Name, u.FullName, e.EntryDate
END